﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Spelprojekt.View
{
    class Particle
    {
        public Vector2 m_position;
        public Vector2 m_speed;
        public Vector2 m_acceleration;
        public float m_size;
        public Color m_color;
        public float m_timeToLive;

        public Particle()
        {
            m_position = new Vector2();
            m_speed = new Vector2();
            m_acceleration = new Vector2();
            m_size = 1.0f;
            m_color = Color.White;
            m_timeToLive = -1;
        }

        public Particle(Vector2 a_position, Vector2 a_acceleration, float a_size, Color a_color, float a_timeToLive)
        {
            m_position = a_position;            
            m_acceleration = a_acceleration;
            m_size = a_size;
            m_color = a_color;
            m_timeToLive = a_timeToLive;
        }        

        public Particle(Vector2 a_position, Vector2 a_speed, Vector2 a_acceleration, float a_size, Color a_color, float a_timeToLive)
        {
            m_position = a_position;
            m_speed = a_speed;
            m_acceleration = a_acceleration;
            m_size = a_size;
            m_color = a_color;
            m_timeToLive = a_timeToLive;
        }

        public void UpdateParticle(float a_elapsedTime)
        {
            //update fall speed
            m_speed += m_acceleration;

            //update position
            m_position += m_speed * a_elapsedTime;

            //update live time
            m_timeToLive -= a_elapsedTime;

            //changes size
            m_size -= 0.01f;
            if (m_size < 0)
            {
                m_size = 0.0f;
            }
            //alpha
            /*
            if (m_color.A > 5)
            {
                m_color.A -= 5;
            }
            else
            {
                m_color.A = 0;
            }*/
        }

        public bool IsActive()
        {
            if (m_timeToLive < 0)
            {
                return false;
            }
            return true;
        }

    }
}
